NOTICE: By continued use of this site you understand and agree to the binding Terms of Service and Privacy Policy.
// ==UserScript== // @name Hide posts by Flairs [Reddit] // @namespace https://www.reddit.com/ // @version 1.5 // @description Hide posts by Flairs [Reddit] // @author Reydan // @match https://www.reddit.com/* // @grant none // @license MIT // @copyright 2019, Reydan (https://openuserjs.org/users/Reydan) // ==/UserScript== window.flag = false; window.flairs = ["Парень","Мем"]; window.word_title = []; window._waitForHide = function _waitForHide() { const container = document.getElementById('2x-container'); if (container !== undefined) { const divs = container.getElementsByTagName("div"); for (let i = 0; i < divs.length; i++) { loop_for: if ( (divs[i].id.indexOf('t3_') === 0) && (divs[i].className.indexOf('scrollerItem') === 0) ) { //console.log('Post Title:',divs[i].getElementsByTagName('a')[3].innerText); const spans = divs[i].getElementsByTagName('div'); for (let j = 0; j < spans.length; j++) { if ( ((spans[j].className.indexOf('s1v') === 0) | (spans[j].className.indexOf('s8r') === 0)) ) { if (window.flairs.indexOf(spans[j].innerText)!==-1) { console.log('Find flair:',spans[j].innerText,'-> [Hidden]') divs[i].style.display = "none"; break; } else { console.log('Find flair:',spans[j].innerText) } } else { if (spans[j].className.indexOf('lrzZ8b0L6AzLkQj5Ww7H1') === 0) { const sp = divs[i].getElementsByTagName('span'); for (let k = 0; k < sp.length; k++) { if (window.flairs.indexOf(sp[k].innerText)!==-1) { console.log('Find flair:',sp[k].innerText,'-> [Hidden]') divs[i].style.display = "none"; break; } else { console.log('Find flair:',spans[j].innerText) } } } else { if (spans[j].className.indexOf('_3wiKjmhpIpoTE2r5KCm2o6') === 0) { console.log('Post Title:',spans[j].innerText); for (let k = 0; k < window.word_title.length; k++) { if (spans[j].innerText.indexOf(window.word_title[k]) !== -1) { console.log('Find text[',window.word_title[k],'] in Title -> [Hidden]') divs[i].style.display = "none"; break loop_for; } } } } } } } } } else { setTimeout(_waitForHide, 10); } }; XMLHttpRequest.prototype.realOpen = XMLHttpRequest.prototype.open; const newOpen = function (method, url, async, user, password) { this.addEventListener("readystatechange", function () { if (this.readyState === 4) { if (window.flag) { window.flag = false; setTimeout(window._waitForHide, 0); } } }, false); this.realOpen(method, url, async, user, password); }; XMLHttpRequest.prototype.open = newOpen; XMLHttpRequest.prototype.realSend = XMLHttpRequest.prototype.send; const newSend = function (vData) { try { const arg = JSON.parse(vData); if( (arg[1].hasOwnProperty('lst')) && (arg[1].lst[0]==="rec") ) { window.flag = true; } } catch (e) { } this.realSend(vData); }; XMLHttpRequest.prototype.send = newSend;